﻿<html>

<head>
${inc:/action/pub/common}
<title>分房政策信息</title>

</head>

<body>
<center>
<div id="divForm">
<form name="form1" onsubmit="return insertForm()" action="${def:context}${def:actionroot}/update" 
        method="POST" target="insertFrame">
<input type="hidden" name="policy_tuid" value="${fld:id}">
<table width="100%" class="grid">
 <caption><font size="5"><b>分房政策信息</b></font><br/><br/></caption>
  <tr align="center">
    <th></th>
    <th>是否为坐地户</th>
    <th>是否独生子女</th>
	<th>离婚丧偶情况</th>
    <th>家庭人口数<br>(单位:个)</th>
	<th>正房间数<br>(单位:间)</th>
	<th>应分户型</th>
	<th>可增户型</th>
	<!--th>可兑顶<br>最大面积</th>
    <th>应分面积<br>(单位:平方米)</th>
    <th>可增面积<br>(单位:平方米)</th>
    <th>兑顶单价<br>(单位:元)</th>
    <th>应分单价<br>(单位:元)</th>
    <th>增档单价<br>(单位:元)</th>
    <th>超档单价<br>(单位:元)</th-->

    <th>备注说明</th>
  </tr>
 <tbody id="gridBody">
  <rows>
  <tr>
    <td align="center"><img src="${def:context}/images/clear.gif" onclick="deleteRow(this.parentNode.parentNode.sectionRowIndex);" border="0" class="tool" title="删除"></td>
    <td align="center"><input type="hidden" name="is_local" value="${fld:is_local}">
        <select name="h_is_local" onchange="selectOnchange(this)">
            <option value="">请选择</option>
            <option value="0">&nbsp;外来户&nbsp;</option>
            <option value="1">&nbsp;坐地户&nbsp;</option>
        </select>
    </td>
    <td align="center"><input type="hidden" name="is_single" value="${fld:is_single}">
        <select name="h_is_single" onchange="selectOnchange(this)">
            <option value="">请选择</option>
            <option value="0">&nbsp;否&nbsp;</option>
            <option value="1">&nbsp;是&nbsp;</option>
        </select>
    </td>
	<td align="center"><input type="hidden" name="single_status" value="${fld:single_status}">
        <select name="h_single_status" onchange="selectOnchange(this)">
            <option value="">请选择</option>
            <option value="0">无</option>
            <option value="1">&nbsp;离婚&nbsp;</option>
			<option value="2">&nbsp;丧偶&nbsp;</option>
        </select>
    </td>
    <td align="center"><input type="hidden" name="people_number" value="${fld:people_number}">
        <select name="h_people_number" onchange="selectOnchange(this)">
            <option value="">请选择</option>
            <option value="1">&nbsp;1&nbsp;</option>
            <option value="2">&nbsp;2&nbsp;</option>
            <option value="3">&nbsp;3&nbsp;</option>
            <option value="4">&nbsp;4&nbsp;</option>
            <option value="5">&nbsp;5&nbsp;</option>
            <option value="6">&nbsp;6&nbsp;</option>
            <option value="7">&nbsp;7&nbsp;</option>
            <option value="8">&nbsp;8&nbsp;</option>
            <option value="9">&nbsp;9&nbsp;</option>
        </select>
    </td>
	<td align="center"><input type="hidden" name="house_number" value="${fld:house_number}">
        <select name="h_house_number" onchange="selectOnchange(this)">
            <option value="">请选择</option>
            <option value="0">&nbsp;0&nbsp;</option>
			<option value="1">&nbsp;1&nbsp;</option>
            <option value="2">&nbsp;2&nbsp;</option>
            <option value="3">&nbsp;3&nbsp;</option>
            <option value="4">&nbsp;4&nbsp;</option>
            <option value="5">&nbsp;5&nbsp;</option>
            <option value="6">&nbsp;6&nbsp;</option>
            <option value="7">&nbsp;7&nbsp;</option>
            <option value="8">&nbsp;8&nbsp;</option>
            <option value="9">&nbsp;9&nbsp;</option>
        </select>
    </td>
	<td align="center"><input type="hidden" name="house_type_yingfen" value="${fld:house_type_yingfen}">
        <select name="h_house_type_yingfen" onchange="selectOnchange(this)">
            <option value="">请选择</option>
			<srows>
            <option value="${fld:s_tuid}">&nbsp;${fld:s_type}&nbsp;</option>
			</srows>
        </select>
    </td>
	<td align="center"><input type="hidden" name="house_type_kezeng" value="${fld:house_type_kezeng}">
        <select name="h_house_type_kezeng" onchange="selectOnchange(this)">
            <option value="">请选择</option>
			<srows>
            <option value="${fld:s_tuid}">&nbsp;${fld:s_type}&nbsp;</option>
			</srows>
        </select>
    </td>
    <!--td align="center">
        <input name="duiding_maxarea_zheng" type="text" size="4" maxlength="10" value="${fld:duiding_maxarea_zheng}">
    </td-->
    <!--td align="center">
        <input name="duiding_maxarea_xiao" type="text" size="4" maxlength="10" value="${fld:duiding_maxarea_xiao}">
    </td-->
    <!--td align="center">
        <input name="yingfen_area" type="text" size="4" maxlength="10" value="${fld:yingfen_area}">
    </td>
    <td align="center">
        <input name="kezeng_area" type="text" size="4" maxlength="10" value="${fld:kezeng_area}">
    </td>
    <td align="center">
        <input name="duiding_price" type="text" size="4" maxlength="10" value="${fld:duiding_price}">
    </td>
    <td align="center">
        <input name="yingfen_price" type="text" size="4" maxlength="10" value="${fld:yingfen_price}">
    </td>
    <td align="center">
        <input name="zengdang_price" type="text" size="4" maxlength="10" value="${fld:zengdang_price}">
    </td>
    <td align="center">
        <input name="chaodang_price" type="text" size="4" maxlength="10" value="${fld:chaodang_price}">
    </td-->
    <td align="center">
        <textarea cols="10" rows="2" name="remark">${fld:remark}</textarea>
    </td>
  </tr>
  </rows>
  <tr>
    <td align="center"><img src="${def:context}/images/clear.gif" onclick="deleteRow(this.parentNode.parentNode.sectionRowIndex);" border="0" class="tool" title="删除"></td>
    <td align="center"><input type="hidden" name="is_local" value="">
        <select name="h_is_local" onchange="selectOnchange(this)">
            <option value="">请选择</option>
            <option value="0">&nbsp;外来户&nbsp;</option>
            <option value="1">&nbsp;坐地户&nbsp;</option>
        </select>
    </td>
    <td align="center"><input type="hidden" name="is_single" value="">
        <select name="h_is_single" onchange="selectOnchange(this)">
            <option value="">请选择</option>
            <option value="0">&nbsp;否&nbsp;</option>
            <option value="1">&nbsp;是&nbsp;</option>
        </select>
    </td>
	<td align="center"><input type="hidden" name="single_status" value="">
        <select name="h_single_status" onchange="selectOnchange(this)">
            <option value="">请选择</option>
            <option value="0">无</option>
            <option value="1">&nbsp;离婚&nbsp;</option>
			<option value="2">&nbsp;丧偶&nbsp;</option>
        </select>
    </td>
    <td align="center"><input type="hidden" name="people_number" value="">
        <select name="h_people_number" onchange="selectOnchange(this)">
            <option value="">请选择</option>
            <option value="1">&nbsp;1&nbsp;</option>
            <option value="2">&nbsp;2&nbsp;</option>
            <option value="3">&nbsp;3&nbsp;</option>
            <option value="4">&nbsp;4&nbsp;</option>
            <option value="5">&nbsp;5&nbsp;</option>
            <option value="6">&nbsp;6&nbsp;</option>
            <option value="7">&nbsp;7&nbsp;</option>
            <option value="8">&nbsp;8&nbsp;</option>
            <option value="9">&nbsp;9&nbsp;</option>
        </select>
    </td>
	<td align="center"><input type="hidden" name="house_number" value="">
        <select name="h_house_number" onchange="selectOnchange(this)">
            <option value="">请选择</option>
			<option value="0">&nbsp;0&nbsp;</option>
            <option value="1">&nbsp;1&nbsp;</option>
            <option value="2">&nbsp;2&nbsp;</option>
            <option value="3">&nbsp;3&nbsp;</option>
            <option value="4">&nbsp;4&nbsp;</option>
            <option value="5">&nbsp;5&nbsp;</option>
            <option value="6">&nbsp;6&nbsp;</option>
            <option value="7">&nbsp;7&nbsp;</option>
            <option value="8">&nbsp;8&nbsp;</option>
            <option value="9">&nbsp;9&nbsp;</option>
        </select>
    </td>
	<td align="center"><input type="hidden" name="house_type_yingfen" value="">
        <select name="h_house_type_yingfen" onchange="selectOnchange(this)">
            <option value="">请选择</option>
			<srows>
            <option value="${fld:s_tuid}">&nbsp;${fld:s_type}&nbsp;</option>
			</srows>
        </select>
    </td>
	<td align="center"><input type="hidden" name="house_type_kezeng" value="">
        <select name="h_house_type_kezeng" onchange="selectOnchange(this)">
            <option value="">请选择</option>
			<srows>
            <option value="${fld:s_tuid}">&nbsp;${fld:s_type}&nbsp;</option>
			</srows>
        </select>
    </td>
    <!--td align="center">
        <input name="duiding_maxarea_zheng" type="text" size="4" maxlength="10" value="">
    </td-->
    <!--td align="center">
        <input name="duiding_maxarea_xiao" type="text" size="4" maxlength="10" value="">
    </td-->
    <!--td align="center">
        <input name="yingfen_area" type="text" size="4" maxlength="10" value="">
    </td>
    <td align="center">
        <input name="kezeng_area" type="text" size="4" maxlength="10" value="">
    </td>

    <td align="center">
        <input name="duiding_price" type="text" size="4" maxlength="10" value="">
    </td>
    <td align="center">
        <input name="yingfen_price" type="text" size="4" maxlength="10" value="">
    </td>
    <td align="center">
        <input name="zengdang_price" type="text" size="4" maxlength="10" value="">
    </td>
    <td align="center">
        <input name="chaodang_price" type="text" size="4" maxlength="10" value="">
    </td-->
    <td align="center">
        <textarea cols="10" rows="2" name="remark"></textarea>
    </td>
  </tr>
  </tbody>
  <tr>
    <th colspan="17" align="center">
        <input type="submit" value="提交" class="cmd" name="submit"><input type="button" value="添加" onclick="addRow();" class="cmd" name="addBtn"><input type="button" value="返回" onclick="return gotoMaster(true);" class="cmd" name="backBtn">
    </th>
  </tr>
</table>
</form>
<iframe name="insertFrame" style="display:none">
</iframe>
</div>
<div id="divStatus" class="alert" style="text-align:left; display:none;color:gray;width:150px;font-weight:bold;font-family:Arial">
    <img src="${def:context}/images/progress.gif"> 请稍候...
</div>
</center>

</body>

</html>

<script language="javascript">
String.prototype.Trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

function MyCheckMoney(num,obj)
{
    var input = obj.value.Trim();
    var pos1 = input.indexOf(".");
    var pos2 = input.lastIndexOf(".");
    var charset = "1234567890.";
    if ((pos1 != pos2)||(!CheckChar(charset, input, true))) {
        alert ("数据格式不正确，只可包含数字和一个“.”！");
        obj.focus();
        obj.select();
        return false;
    }
    if(num==null || num=="")
    {
        var output = eval((Math.round(input*100))/100);
        obj.value=output;
    }
    else
    {
        var i_exp=Math.pow(10,num)
        var output = eval((Math.round(input*i_exp))/i_exp);
        obj.value=output;
    }
    return true;
}

//字段校验
function insertForm(){
    var b = document.getElementById("gridBody");
    var intDataLength = b.rows.length;

    //数据校验
    for (i=0;i<intDataLength;i++)
    {
        //alert("intDataLength:"+intDataLength+"\n :"+typeof(document.getElementsByName("is_local")[0]));
        if(document.getElementsByName("is_local")[i].value.Trim()==""){
            alert("请选择是否为坐地户！");
            return false;
        }
        if(document.getElementsByName("is_single")[i].value.Trim()==""){
            alert("请选择是否独生子女！");
            return false;
        }
		if(document.getElementsByName("single_status")[i].value.Trim()==""){
            alert("请选择离婚丧偶情况！");
            return false;
        }
        if(document.getElementsByName("people_number")[i].value.Trim()==""){
            alert("请选择家庭人口！");
            return false;
        }
		if(document.getElementsByName("house_number")[i].value.Trim()==""){
            alert("请选择正房间数！");
            return false;
        }
		if(document.getElementsByName("house_type_yingfen")[i].value.Trim()==""){
            alert("请选择应分户型！");
            return false;
        }
		if(document.getElementsByName("house_type_kezeng")[i].value.Trim()==""){
            alert("请选择可增户型！");
            return false;
        }
		/**
		if(document.getElementsByName("duiding_maxarea_zheng")[i].value.Trim()==""){
            alert("可兑顶最大面积不能为空！");
            document.getElementsByName("duiding_maxarea_zheng")[i].focus();
            return false;
        }
        if(!MyCheckMoney(2,document.getElementsByName("duiding_maxarea_zheng")[i])) return false;

//        if(document.getElementsByName("duiding_maxarea_xiao")[i].value.Trim()==""){
//            alert("可兑顶最大小房面积不能为空！");
//            document.getElementsByName("duiding_maxarea_xiao")[i].focus();
//            return false;
//        }
//        if(!MyCheckMoney(2,document.getElementsByName("duiding_maxarea_xiao")[i])) return false;

        if(document.getElementsByName("yingfen_area")[i].value.Trim()==""){
            alert("应分面积不能为空！");
            document.getElementsByName("yingfen_area")[i].focus();
            return false;
        }
        if(!MyCheckMoney(2,document.getElementsByName("yingfen_area")[i])) return false;

        if(document.getElementsByName("kezeng_area")[i].value.Trim()==""){
            alert("可增面积不能为空！");
            document.getElementsByName("kezeng_area")[i].focus();
            return false;
        }
        if(!MyCheckMoney(2,document.getElementsByName("kezeng_area")[i])) return false;

        if(document.getElementsByName("duiding_price")[i].value.Trim()==""){
            alert("兑顶价格不能为空！");
            document.getElementsByName("duiding_price")[i].focus();
            return false;
        }
        if(!MyCheckMoney(2,document.getElementsByName("duiding_price")[i])) return false;

        if(document.getElementsByName("yingfen_price")[i].value.Trim()==""){
            alert("应分价格不能为空！");
            document.getElementsByName("yingfen_price")[i].focus();
            return false;
        }
        if(!MyCheckMoney(2,document.getElementsByName("yingfen_price")[i])) return false;

        if(document.getElementsByName("zengdang_price")[i].value.Trim()==""){
            alert("增档价格不能为空！");
            document.getElementsByName("zengdang_price")[i].focus();
            return false;
        }
        if(!MyCheckMoney(2,document.getElementsByName("zengdang_price")[i])) return false;

        if(document.getElementsByName("chaodang_price")[i].value.Trim()==""){
            alert("超档价格不能为空！");
            document.getElementsByName("chaodang_price")[i].focus();
            return false;
        }
        if(!MyCheckMoney(2,document.getElementsByName("chaodang_price")[i])) return false;
		*/
        if(document.getElementsByName("remark")[i].value.Trim().length> 64){
            alert("备注信息长度不能大于120，请重新输入！");
            document.getElementsByName("remark")[i].focus();
            return false;
        }
    }

    document.form1.submit.disabled = true;
    document.form1.addBtn.disabled = true;
    document.form1.backBtn.disabled = true;
    document.getElementById("divStatus").style.display="";
    return true;
}

function insertOK()
{
    document.getElementById("divStatus").style.display="none";	
    document.form1.submit.disabled = false;
    document.form1.addBtn.disabled = false;
    document.form1.backBtn.disabled = false;
    alert("保存成功.");
}

function updateError(msg)
{
    document.getElementById("divStatus").style.display="none";
    document.form1.submit.disabled = false;
    document.form1.addBtn.disabled = false;
    document.form1.backBtn.disabled = false;
    alert(msg);
}

function addRow()
{
    var b = document.getElementById("gridBody");

    var x = b.insertRow(-1);
    
    var d = b.rows[0];

    for (i=0;i<d.cells.length;i++)
    {
        var c = x.insertCell(-1);
        c.innerHTML = d.cells[i].innerHTML;
        c.align = d.cells[i].align;
        c.valign = d.cells[i].valign;
    }
    
    document.forms[0].is_local[b.rows.length-1].value = "";
    document.forms[0].h_is_local[b.rows.length-1].options[0].selected=true;
    document.forms[0].is_single[b.rows.length-1].value = "";
    document.forms[0].h_is_single[b.rows.length-1].options[0].selected=true;
	document.forms[0].single_status[b.rows.length-1].value = "";
    document.forms[0].h_single_status[b.rows.length-1].options[0].selected=true;
    document.forms[0].people_number[b.rows.length-1].value = "";
	document.forms[0].h_people_number[b.rows.length-1].options[0].selected=true;
	document.forms[0].house_type_yingfen[b.rows.length-1].value = "";
	document.forms[0].h_house_type_yingfen[b.rows.length-1].options[0].selected=true;
	document.forms[0].house_type_kezeng[b.rows.length-1].value = "";
	document.forms[0].h_house_type_kezeng[b.rows.length-1].options[0].selected=true;
/*
	document.forms[0].duiding_maxarea_zheng[b.rows.length-1].value = "";
//	document.forms[0].duiding_maxarea_xiao[b.rows.length-1].value = "";

    document.forms[0].house_number[b.rows.length-1].value = "";
	document.forms[0].h_house_number[b.rows.length-1].options[0].selected=true;
	document.forms[0].yingfen_area[b.rows.length-1].value = "";
	document.forms[0].kezeng_area[b.rows.length-1].value = "";
	document.forms[0].duiding_price[b.rows.length-1].value = "";
	document.forms[0].yingfen_price[b.rows.length-1].value = "";
	document.forms[0].zengdang_price[b.rows.length-1].value = "";
	document.forms[0].chaodang_price[b.rows.length-1].value = "";
*/
    document.forms[0].remark[b.rows.length-1].value = "";
}

function deleteRow(j)
{	
    var b = document.getElementById("gridBody");
    if(b.rows.length==1)
    {
        alert("至少要保留一条信息！");
    }
    else
    {
        b.deleteRow(j);
    }
}

function selectOnchange(obj){
    obj.parentNode.childNodes[0].value = obj.value;
}

//2010-4-27 anthony
window.onload = function(){
    var b = document.getElementById("gridBody");
    var intDataLength = b.rows.length;
    if(intDataLength > 1){
        deleteRow(intDataLength-1);
        
        intDataLength = b.rows.length;
        for (j=0;j<intDataLength;j++)
        {
            var is_local = document.getElementsByName("is_local")[j].value;
            comboObj = document.getElementsByName("h_is_local")[j];
            setComboValue(comboObj,is_local);

            var is_single = document.getElementsByName("is_single")[j].value;
            comboObj = document.getElementsByName("h_is_single")[j];
            setComboValue(comboObj,is_single);

			var single_status = document.getElementsByName("single_status")[j].value;
            comboObj = document.getElementsByName("h_single_status")[j];
            setComboValue(comboObj,single_status);

            var people_number = document.getElementsByName("people_number")[j].value;
            comboObj = document.getElementsByName("h_people_number")[j];
            setComboValue(comboObj,people_number);

			var house_type_yingfen = document.getElementsByName("house_type_yingfen")[j].value;
            comboObj = document.getElementsByName("h_house_type_yingfen")[j];
            setComboValue(comboObj,house_type_yingfen);

			var house_type_kezeng = document.getElementsByName("house_type_kezeng")[j].value;
            comboObj = document.getElementsByName("h_house_type_kezeng")[j];
            setComboValue(comboObj,house_type_kezeng);

            var house_number = document.getElementsByName("house_number")[j].value;
            comboObj = document.getElementsByName("h_house_number")[j];
            setComboValue(comboObj,house_number);
        }

    }
}
function setComboValue(comboObj,hiddenValue){
    var val = hiddenValue;
    for(i=0;i<comboObj.options.length;i++){
        if(hiddenValue == comboObj.options[i].value){
            comboObj.options[i].selected = true;
            break;
        }
    }
}

function gotoMaster(flag){
    var url = "${def:context}/action/dq/policy/crud";
    if(flag == true){
        if(window.confirm("确定放弃修改？") == true){
            document.location.href = url;
        }
    }else{
        document.location.href = url;
    }
    
}
</script>
    